<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="flashList" checkbox="false" fitColumns="true" title="实验中心视频展示" actionUrl="cms-flash.do?console-datagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建日期"  field="createDate" formatter="yyyy-MM-dd" hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="视频名称"  field="title"   query="true" queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="排序"  field="sortOrder"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="是否发布"  field="isOnline"  query="true"   queryMode="single"  
   	width="120" formatterjs="function(v,rec){return v==1? '是':'否'}"
   	replace="已发布_1,未发布_0"
   	></t:dgCol>
   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
   <t:dgFunOpt  funname="setOnline(id)" title="发布" exp="isOnline#eq#0,null"/>
   <t:dgFunOpt  funname="setOffline(id)" title="下线" exp="isOnline#eq#1"/>
<%--       <t:dgFunOpt  funname="play(id)" title="播放" exp="isOnline#eq#0,null"/> --%>
   <t:dgFunOpt  funname="editItemDetail({'编辑'},{'cms-flash.do?goUpdate'},id,{'800'},{'500'})" title="编辑"  />
   <t:dgFunOpt  funname="showItemDetail({'查看'},{'cms-flash.do?goUpdate'},id,{'800'},{'500'})" title="查看"  />
   <t:dgDelOpt title="删除" url="cms-flash.do.do?doDel&id={id}" />
   <t:dgToolBar title="录入" icon="icon-add" url="cms-flash.do?goAdd" funname="add" height="500" width="800"></t:dgToolBar>
 
  
  </t:datagrid>
  </div>
 </div>
 <script type="text/javascript">

 
 function setOffline(id,state){
	 $.dialog.confirm('所有视频都下线时，默认优先显示第一个视频，您确定下线吗?', function(r) {
		   if (r) {
	 			setOnlineState(id,0);
			}
		}); 
}
 
function setOnlineState(id,state){
	
		$.ajax({
			url:"cms-flash.do?setonline&id="+id+"&state="+state,
			success:function(data){
				data = $.parseJSON(data);
				if(data.success){
					tip("操作成功");
					reloadTable();
				}else{
					tip("操作失败！");
				}
			}
		});

}
//上线是1  下线是 0 
function setOnline(id){
	 $.dialog.confirm('只能发布一个中心视频，当前视频发布，其它视频将下线，您确定发布吗?', function(r) {
		   if (r) {
			setOnlineState(id,1);
			}
		}); 
}
 </script>